package com.example.task1.ui.AllService.traffic;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.bean.TrafficOrderListBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class TrafficOrderListAdapter extends BaseAdapter<TrafficOrderListBean.RowsDTO> {

    private Context context;

    private List<TrafficOrderListBean.RowsDTO> mData = new ArrayList<>();
    private TextView tvName;
    private TextView tvUserName;
    private TextView tvPlateNo;
    private TextView tvTime;

    public TrafficOrderListAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected void setData(List<TrafficOrderListBean.RowsDTO> rows) {
        mData.clear();
        mData.addAll(rows);
        notifyDataSetChanged();
    }

    @Override
    protected int getLayout() {
        return R.layout.trafficeorderlist;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<TrafficOrderListBean.RowsDTO> getData() {
        return mData;
    }

    @Override
    protected void onBind(myHolder holder, TrafficOrderListBean.RowsDTO date) {
        tvName.setText(date.getPlaceName());
        tvPlateNo.setText(date.getPlateNo());
        tvUserName.setText(date.getUserName());
        tvTime.setText("---" + date.getAptTime());
    }

    @Override
    protected void holder(View itemView) {
        initView(itemView);
    }

    private void initView(View view) {
        tvName = (TextView) view.findViewById(R.id.tv_name);
        tvUserName = (TextView) view.findViewById(R.id.tv_userName);
        tvPlateNo = (TextView) view.findViewById(R.id.tv_plateNo);
        tvTime = (TextView) view.findViewById(R.id.tv_time);
    }
}
